@echo off
chcp 65001 >nul
title Laravel 高级缓存清理
echo ========================================
echo        Laravel 高级缓存清理工具
echo ========================================
echo.

if not exist "artisan" (
    echo 错误：请在 Laravel 项目根目录运行
    pause
    exit /b 1
)

set /p choice="是否清除所有缓存？(y/n): "
if /i "%choice%" neq "y" (
    echo 操作已取消
    pause
    exit /b 0
)

echo.
echo 🧹 执行基础清理...
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear

echo.
echo 📦 重新生成自动加载...
composer dump-autoload

echo.
set /p advanced="是否执行高级清理？(包括优化和事件清除)(y/n): "
if /i "%advanced%" equ "y" (
    echo.
    echo ⚡ 清除已编译的服务...
    php artisan clear-compiled
    
    echo.
    echo 🎯 清除事件缓存...
    php artisan event:clear
    
    echo.
    echo 🔥 重新优化...
    php artisan optimize
)

echo.
echo ✅ 所有操作完成！
echo.
pause
